#include <vector>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    long long nums[5843], a, b, c, d;
    nums[1] = 1;
    a = b = c = d = 1;
    for (int i = 2; i <= 5842; i++)
    {
        nums[i] = min(min(nums[a] * 2, nums[b] * 3), min(nums[c] * 5, nums[d] * 7));
        if (nums[i] == nums[a] * 2)
            a++;
        if (nums[i] == nums[b] * 3)
            b++;
        if (nums[i] == nums[c] * 5)
            c++;
        if (nums[i] == nums[d] * 7)
            d++;
    }

    int n;
    string s;
    while (cin >> n && n != 0)
    {
        if (n % 10 == 1 && n % 100 != 11)
            s = "st";
        else if (n % 10 == 2 && n % 100 != 12)
            s = "nd";
        else if (n % 10 == 3 && n % 100 != 13)
            s = "rd";
        else
            s = "th";
        cout << "The " << n << s << " humble number is " << nums[n] << "." << endl;
    }

    return 0;
}